<?php
namespace core;



class Api
{
  static function out($result,$data,$code=0){
		// header('Cache-Control: no-cache, must-revalidate');
		// header("Pragma: no-cache");
		// header('Content-type: application/json');

		if ($result){
			$result=true;
		}else{
			$result=false;
		}
		$send=array(
			'result'=>$result,
      'code'=>$code,
			'data'=>$data,
		);
		json($send)->send();
    die();
	}
	static function error($data,$code=0){
		return self::out(false,$data,$code);
	}
	static function ok($data,$code=0){
		return self::out(true,$data,$code);
	}
  static function get(){
    $data=file_get_contents('php://input');
    return json_decode($data,1);
  }

}
